import VueRouter from 'vue-router'
// 引入组件
import index from '../pages/index'
import homePage from '../pages/homePage'
import algorithm from '../pages/algorithm'
import demand from '../pages/demand'
import detail from '../pages/detail'
import login from "../pages/login"
import register from "../pages/register"
import message from "../pages/message"

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

// 创建一个路由器
export default new VueRouter({
    routes:[
        {
            path:'/index',
            component:index,
            redirect:'/homepage',
            children:[
                {
                    path:'/homepage',  //首页
                    name:"homepage",
                    meta:{
                        title:"首页"
                    },
                    component:homePage
                },
                {
                    path:'/algorithm', //算法广场
                    name:'algorithm',
                    meta:{
                        title:"算法广场"
                    },
                    component:algorithm
                },
                {
                    path:'/algorithm/detail/:algoid',  //算法详情
                    name:"algoDetail",
                    meta:{
                        title:"算法详情"
                    },
                    component:detail
                },
                {
                    path:'/demand',  //需求广场
                    name:'demand',
                    meta:{
                        title:"需求广场"
                    },
                    component:demand
                },
                {
                    path:'/demand/detail/:demandid',  //需求详情
                    name:"demandDetail",
                    meta:{
                        title:"需求详情"
                    },
                    component:detail
                },
                {
                    path:'/message',           //信息
                    name:"message",
                    meta:{
                        title:"信息"
                    },
                    component:message
                }
            ]
        },
        {
            path:'/login',
            component:login,
            meta:{
                title:"登录"
            },
            name:'login'
        },
        {
            path:'register',
            component:register,
            meta:{
                title:"注册"
            },
            name:'register'
        }
    ]
})

